---
id: 655a1a6d8c44db154b00c909
title: الخطوة 24
challengeType: 20
dashedName: step-24
---

# --description--

Write another `if` statement that checks if the target key is less than the key of the current node.

Inside the `if` block, return the result of calling the `_search` method with the left child of the current node and `key` as the arguments.

# --hints--

You should write another `if` statement to check if `key` < `node.key`.

```js
const after_split = code.split('def search(self, key):')[1];
assert.match(after_split, /if\s+key\s+<\s+node\.key/);
```

You should return `self._search(node.left, key)` from your new `if` block.

```js
({ test: () => assert.match(code, /return\s+self\._search\(\s*node\.left\s*,\s*key\s*\)/) });
```

# --seed--

## --seed-contents--

```py
class TreeNode:
    def __init__(self, key):
        self.key = key
        self.left = None
        self.right = None

class BinarySearchTree:
    def __init__(self):
        self.root = None

    def insert(self,key):
        self.root = self._insert(self.root, key)

    def _insert(self, node, key):
        if node is None:
            return TreeNode(key)
        if key < node.key:
            node.left = self._insert(node.left, key)
        elif key > node.key:
            node.right = self._insert(node.right, key)
        return node

    def search(self, key):
        return self._search(self.root, key)
--fcc-editable-region--
    def _search(self, node, key):
        if node is None or node.key == key:
            return node                
--fcc-editable-region--
```
